package cn.stylefeng.guns.modular.order.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.order.entity.OrderOutcountXlb;
import cn.stylefeng.guns.modular.order.mapper.OrderOutcountXlbMapper;
import cn.stylefeng.guns.modular.order.model.params.OrderOutcountXlbParam;
import cn.stylefeng.guns.modular.order.model.result.OrderOutcountXlbResult;
import  cn.stylefeng.guns.modular.order.service.OrderOutcountXlbService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 新零帮出库汇总 服务实现类
 * </p>
 *
 * @author zhucx
 * @since 2023-09-30
 */
@Service
public class OrderOutcountXlbServiceImpl extends ServiceImpl<OrderOutcountXlbMapper, OrderOutcountXlb> implements OrderOutcountXlbService {

    @Override
    public void add(OrderOutcountXlbParam param){
        OrderOutcountXlb entity = getEntity(param);
        this.save(entity);
    }

    @Override
    public void delete(OrderOutcountXlbParam param){
        this.removeById(getKey(param));
    }

    @Override
    public void update(OrderOutcountXlbParam param){
        OrderOutcountXlb oldEntity = getOldEntity(param);
        OrderOutcountXlb newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }

    @Override
    public OrderOutcountXlbResult findBySpec(OrderOutcountXlbParam param,Long operateId){
        return this.baseMapper.findBySpec(param,operateId);
    }

    @Override
    public List<OrderOutcountXlbResult> findListBySpec(OrderOutcountXlbParam param){
        return null;
    }

    @Override
    public LayuiPageInfo findPageBySpec(OrderOutcountXlbParam param,String condition, Long operateId){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageListNew(pageContext, param,condition, operateId);
        return LayuiPageFactory.createPageInfo(page);
    }

    private Serializable getKey(OrderOutcountXlbParam param){
        return param.getId();
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }

    private OrderOutcountXlb getOldEntity(OrderOutcountXlbParam param) {
        return this.getById(getKey(param));
    }

    private OrderOutcountXlb getEntity(OrderOutcountXlbParam param) {
        OrderOutcountXlb entity = new OrderOutcountXlb();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }

	@Override
	public boolean saveBatchList(List<OrderOutcountXlbParam> list) {
		return this.baseMapper.saveBatchList(list);
	}

	@Override
	public OrderOutcountXlbResult checkyouwu(OrderOutcountXlbParam ch) {
		return this.baseMapper.checkyouwu(ch);
	}

	@Override
	public void deleteBySpec(OrderOutcountXlbParam de) {
		this.baseMapper.deleteBySpec(de);
	}

}
